package com.qf.agro.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qf.agro.common.ResultInfo;
import com.qf.agro.mapper.CropMapper;
import com.qf.agro.pojo.Crop;
import com.qf.agro.service.CropService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author 10202
 * @version V1.0
 * @Project smart-agriculture-parent
 * @Package com.qf.agro.service.impl
 * @Date 2023/7/5 16:34
 */
@Service
public class CropServiceImpl implements CropService {

    @Autowired
    private CropMapper cropMapper;
    @Override
    public ResultInfo getPage(Long page, Long pageSize, String name, String facilitiesId) {
        Page<Crop> cropPage=new Page<>(page,pageSize);
        LambdaQueryWrapper<Crop> lqw =new LambdaQueryWrapper<>();
        lqw.eq(facilitiesId!=null,Crop::getFacilitiesId,facilitiesId);
        lqw.like(name!=null,Crop::getName,name);
        cropPage= cropMapper.selectPage(cropPage,lqw);
        return ResultInfo.success(cropPage);
    }
}
